package com.example.myapplication;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.Timer;
import java.util.TimerTask;

public class Diyi extends AppCompatActivity {
SharedPreferences preferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_diyi);
        preferences=getSharedPreferences("count",MODE_WORLD_READABLE);
        int count=preferences.getInt("count",0);
        if(count==0){
            Timer timer=new Timer();
            TimerTask timerTask=new TimerTask() {
                @Override
                public void run() {
                    Intent intent=new Intent(Diyi.this,Dier.class);
                    startActivity(intent);
                    Diyi.this.finish();
                }
            };
            timer.schedule(timerTask,1000*1);
        }
        SharedPreferences.Editor editor=preferences.edit();
        editor.putInt("count",++count);
        editor.commit();
    }
}
